* convert mapbar_track to Format class.
* const member funcs
legacyformat.h
lowranceusr.h
magellan.h
+ mapbar_track.h
mapfactor.h
mynav.h
navilink.h
legacyformat.h \
lowranceusr.h \
magellan.h \
+ mapbar_track.h \
mapfactor.h \
mynav.h \
navilink.h \
*/
-#include <cstdio> // for SEEK_CUR
+#include "mapbar_track.h"
#include <QChar> // for QChar
#include <QDate> // for QDate
#include <QString> // for QString
#include <QTime> // for QTime
-#include <QVector> // for QVector
-#include "defs.h"
-#include "gbfile.h" // for gbfgetint16, gbfgetint32, gbfseek, gbfclose, gbfopen, gbfile
+#include <cstdio> // for SEEK_CUR
+
+#include "defs.h" // for fatal, Waypoint, track_add_head, track_add_wpt, route_head
+#include "gbfile.h" // for gbfgetint16, gbfgetint32, gbfseek, gbfclose, gbfopen
#include "src/core/datetime.h" // for DateTime
#define MYNAME "mapbar_track"
-static gbfile* fin;
-
-static
-QVector<arglist_t> mapbar_track_args = {
-};
-
/*******************************************************************************
* %%% global callbacks called by gpsbabel main process %%% *
*******************************************************************************/
-static void
-mapbar_track_rd_init(const QString& fname)
+void
+MapbarTrackFormat::rd_init(const QString& fname)
{
fin = gbfopen(fname, "r", MYNAME);
}
-static void
-mapbar_track_rd_deinit()
+void
+MapbarTrackFormat::rd_deinit()
{
gbfclose(fin);
}
-static gpsbabel::DateTime
-read_datetime()
+gpsbabel::DateTime
+MapbarTrackFormat::read_datetime() const
{
int hour = gbfgetint16(fin);
int min = gbfgetint16(fin);
return t;
}
-static const double DIV_RATE = 100000.0f;
-static Waypoint*
-read_waypoint()
+Waypoint*
+MapbarTrackFormat::read_waypoint() const
{
int longitude = gbfgetint32(fin);
int latitude = gbfgetint32(fin);
return ret;
}
-static void
-mapbar_track_read()
+void
+MapbarTrackFormat::read()
{
auto* track = new route_head;
track_add_head(track);
end_flag = gbfgetint32(fin);
}
}
-
-// capabilities below means: we can only read trackpoints.
-
-ff_vecs_t mapbar_track_vecs = {
- ff_type_file,
- { ff_cap_none, (ff_cap)(ff_cap_read), ff_cap_none },
- mapbar_track_rd_init,
- nullptr,
- mapbar_track_rd_deinit,
- nullptr,
- mapbar_track_read,
- nullptr,
- nullptr,
- &mapbar_track_args,
- CET_CHARSET_UTF8, 0
- /* not fixed, can be changed through command line parameter */
- , NULL_POS_OPS,
- nullptr
-};
--- /dev/null
+/*
+ China mapbar navigation track reader for sonim xp3300
+ it's maybe can used in other demo devices of mapbar navigation
+
+ Copyright (C) 2013 xiao jian cheng, azuresky.xjc@gmail.com
+ Copyright (C) 2001-2013 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+#ifndef MAPBAR_TRACK_H_INCLUDED_
+#define MAPBAR_TRACK_H_INCLUDED_
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+
+#include "defs.h" // for ff_cap, arglist_t, ff_cap_none, CET_CHARSET_UTF8, Waypoint, ff_cap_read, ff_type, ff_type_file
+#include "format.h" // for Format
+#include "gbfile.h" // for gbfile
+#include "src/core/datetime.h" // for DateTime
+
+
+class MapbarTrackFormat : public Format
+{
+public:
+ QVector<arglist_t>* get_args() override
+ {
+ return &mapbar_track_args;
+ }
+
+ ff_type get_type() const override
+ {
+ return ff_type_file;
+ }
+
+ QVector<ff_cap> get_cap() const override
+ {
+ /* waypoints, tracks, routes */
+ return { ff_cap_none, (ff_cap)(ff_cap_read), ff_cap_none };
+ }
+
+ QString get_encode() const override
+ {
+ return CET_CHARSET_UTF8;
+ }
+
+ int get_fixed_encode() const override
+ {
+ return 0;
+ }
+
+ void rd_init(const QString& fname) override;
+ void read() override;
+ void rd_deinit() override;
+
+private:
+ /* Constants */
+
+ static constexpr double DIV_RATE = 100000.0f;
+
+ /* Member Functions */
+
+ gpsbabel::DateTime read_datetime() const;
+ Waypoint* read_waypoint() const;
+
+ /* Data Members */
+
+ gbfile* fin{};
+
+ QVector<arglist_t> mapbar_track_args = {
+ };
+};
+#endif // MAPBAR_TRACK_H_INCLUDED_
#include "kml.h"
#include "legacyformat.h"
#include "lowranceusr.h"
+#include "mapbar_track.h"
#include "mapfactor.h"
#include "mynav.h"
#include "nmea.h"
extern ff_vecs_t v900_vecs;
extern ff_vecs_t enigma_vecs;
extern ff_vecs_t format_garmin_xt_vecs;
-extern ff_vecs_t mapbar_track_vecs;
extern ff_vecs_t f90g_track_vecs;
#endif // MAXIMAL_ENABLED
SubripFormat subrip_fmt;
LegacyFormat format_garmin_xt_fmt {format_garmin_xt_vecs};
GarminFitFormat format_fit_fmt;
- LegacyFormat mapbar_track_fmt {mapbar_track_vecs};
+ MapbarTrackFormat mapbar_track_fmt;
LegacyFormat f90g_track_fmt {f90g_track_vecs};
MapfactorFormat mapfactor_fmt;
EnergymproFormat energympro_fmt;